package com.bbva.itradecomex.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import org.apache.log4j.Logger;

import com.bbva.itradecomex.util.SelectItemsUtils;
 
public abstract class SelectItemsBaseConverter implements Converter {
	
	private static final Logger log = Logger.getLogger(SelectItemsBaseConverter.class);

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		if(value != null){
			try {
				return SelectItemsUtils.findValueByStringConversion(context, component,value, this);
			} catch (Exception e) {
				e.printStackTrace();
				log.error(e.getMessage(),e);
			}
		}
		return null;
	}
}